import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class FooterItem extends StatelessWidget {
  String title;
  List<String> items;
  List<String> urls = [];
  double width = 200;
  FooterItem(this.title, this.items, this.urls, this.width);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 165,
      width: width,
      padding: EdgeInsetsDirectional.zero,
      child: Column(
        // mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Text(
            title,
            style: const TextStyle(
                color: Color(0xffDDDDDD), fontFamily: '思源黑体', fontSize: 20),
          ),
          const SizedBox(height: 25),
          Flexible(
            child: ListView.separated(
                padding: EdgeInsetsDirectional.zero,
                shrinkWrap: true,
                itemBuilder: (BuildContext context, index) {
                  String url = urls[index];
                  if (url.isNotEmpty) {
                    return GestureDetector(
                      onTap: () {
                        launchUrl(Uri.parse(url));
                      },
                      child: MouseRegion(
                        cursor: SystemMouseCursors.click,
                        child: Text(
                          items[index],
                          style: const TextStyle(
                              color: Color(0xffDDDDDD),
                              fontFamily: '思源黑体',
                              fontSize: 14,
                              decorationColor: Colors.white,
                              decorationThickness: 2,
                              decoration: TextDecoration.underline),
                        ),
                      ),
                    );
                  }
                  return Text(items[index],
                      style: const TextStyle(
                        color: Color(0xffDDDDDD),
                        fontFamily: '思源黑体',
                        fontSize: 14,
                      ));
                },
                separatorBuilder: (BuildContext context, index) {
                  return const SizedBox(
                    height: 15,
                  );
                },
                itemCount: items.length),
          )
        ],
      ),
    );
  }
}
